﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using NJT.扩展;

namespace FM.Test
{
    [TestClass]
    public class 时间test
    {
        [TestMethod]
        public void TimeSpan转换_test()
        {
            var ti = new TimeSpan(25, 0, 0);
            Assert.AreEqual("1.01:00:00", ti.ToString("c"));

            var a = NJT.转换.时间转换("1.00:00:00");
            Assert.AreEqual(true, a.Item1);
            Assert.AreEqual(new TimeSpan(24, 0, 0), a.Item2);

            a = NJT.转换.时间转换("1.01:00:00");
            Assert.AreEqual(true, a.Item1);
            Assert.AreEqual(ti, a.Item2);

        }

           [TestMethod]
        public void datetime转换_test()
        {
            var ti = new DateTime(2015, 1, 2, 12, 0, 20);
            Assert.AreEqual("2015-01-02T12:00:20", ti.ToString("s"));

            var a = NJT.转换.日期转换("2015-01-02T12:00:20");
            Assert.AreEqual(true, a.Item1);
            Assert.AreEqual(ti, a.Item2);

            string s = "2015-01-02T12_00_20";
            a = NJT.转换.日期转换(s.Replace("_",":"));
            Assert.AreEqual(true, a.Item1);
            Assert.AreEqual(ti, a.Item2);

        }
    }
}
